package skills.jssvc.deu.cn.skillsecond.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import skills.jssvc.deu.cn.skillsecond.MyApplication;
import skills.jssvc.deu.cn.skillsecond.R;
import skills.jssvc.deu.cn.skillsecond.entry.BillMang;

public class BillMangAdapter extends RecyclerView.Adapter<BillMangAdapter.ViewHolder> {
    List<BillMang> billList ;

    public BillMangAdapter(List<BillMang> billList) {
        this.billList = billList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(MyApplication.appContext)
                .inflate(R.layout.item_frag3_billmang, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        BillMang billMang = billList.get(position);
        holder.idTv.setText(String.valueOf(billMang.getId()));
        holder.caridTv.setText(String.valueOf(billMang.getCarid()));
        holder.amountTv.setText(String.valueOf(billMang.getAmount()));
        holder.userTv.setText(String.valueOf(billMang.getUser()));
        holder.timeTv.setText(String.valueOf(billMang.getTime()));
    }

    @Override
    public int getItemCount() {
        return billList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        private TextView idTv,caridTv,amountTv,userTv,timeTv;
        public ViewHolder(View itemView) {
            super(itemView);
            idTv = (TextView) itemView.findViewById(R.id.item_frag3_id_tv);
            caridTv = (TextView) itemView.findViewById(R.id.item_frag3_carid_tv);
            amountTv = (TextView) itemView.findViewById(R.id.item_frag3_amount_tv);
            userTv = (TextView) itemView.findViewById(R.id.item_frag3_user_tv);
            timeTv = (TextView) itemView.findViewById(R.id.item_frag3_time_tv);
        }
    }
}
